package com.shujia.day08.homework;

/*
    2.以面向对象的思想，编写自定义类描述 IT 从业者。设定属性包括：姓名，年龄， 技术方向，工作年限, 工作单位和职务；
    方法包括：工作
    要求：
    1)设置属性的私有访问权限，通过公有的 get,set 方法实现对属性的访问
    2)限定 IT 从业人员必须年满 15 岁，无效信息需提示，并设置默认年龄为 15。
    3)限定“技术方向”是只读属性(只提供 get 方法)
    4)工作方法通过输入参数，接收工作单位和职务，输出个人工作信息
    编写测试类，测试 IT 从业者类的对象及相关方法（测试数据信息自定义）
 */

class ItWorker {
    //姓名，年龄， 技术方向，工作年限, 工作单位和职务
    private String name;
    private int age;
    private String technicalDirection;
    private int workYears;
    private String workUnit;
    private String position;

    public ItWorker() {
    }

    public ItWorker(String name, int age, String technicalDirection, int workYears, String workUnit, String position) {
        this.name = name;
        setAge(age);
        this.technicalDirection = technicalDirection;
        this.workYears = workYears;
        this.workUnit = workUnit;
        this.position = position;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        if (age >= 15) {
            this.age = age;
        } else {
            System.out.println("年龄信息无效!已修改默认年龄为15");
            this.age = 15;
        }
    }

    public String getTechnicalDirection() {
        return technicalDirection;
    }

    public int getWorkYears() {
        return workYears;
    }

    public void setWorkYears(int workYears) {
        this.workYears = workYears;
    }

    public String getWorkUnit() {
        return workUnit;
    }

    public void setWorkUnit(String workUnit) {
        this.workUnit = workUnit;
    }

    public String getPosition() {
        return position;
    }

    public void setPosition(String position) {
        this.position = position;
    }

    public void work() {
        System.out.println("姓名：" + name);
        System.out.println("年龄：" + age);
        System.out.println("技术方向:" + technicalDirection);
        System.out.println("工作年限：" + workYears);
        System.out.println("目前就职于：" + workUnit);
        System.out.println("职务是：" + position);
    }
}

public class Test2 {
    public static void main(String[] args) {
        ItWorker i1 = new ItWorker("马未龙", 35, "数据库维护", 10, "腾讯实业", "数据库维护工程师");
        i1.work();
        System.out.println("=====================================");
        ItWorker i2 = new ItWorker("张凯", 8, "Java开发", 1, "鼎盛科技", "Java开发工程师");
        i2.work();
    }
}
